<template>
  <div>
    <div v-if="skin=='bookmark'" class="bookmark" :style="boxstyle">
        <div class="item-list">

          <div class="tag-vertical discount"> <slot>{{title}}</slot></div>
        </div>
    </div>
    <div v-else class="mark" :style="boxstyle">
      <div class="tricon" :style="style">
        <slot>
          {{title}}
        </slot>
      </div>
    </div>
  </div>

</template>

<script>
export default {
  props:{
    title:{
      type:String
    },
    position:{
      type:String,
      default:'left' // lefet ,right
    },
    bgcolor:{
      type:String,
      default:'#0c60ee'
    },
    skin:{
      type:String
    }
  },
  computed:{
    boxstyle(){
      console.log('=====',this.position)
       if(this.position == 'right'){
         return {
          right:'0px',
          left:'initial'
         }
       }
    },
    style(){
      if(this.position == 'right'){
        return {
          'background-color': this.bgcolor,
          'right': '-58%',
          'left': 'initial',
          '-webkit-transform': 'rotate(45deg)',
          '-o-transform': 'rotate(45deg)',
          '-ms-transform': 'rotate(45deg)',
          'transform':'rotate(45deg)'
        }
      }
      return {
        'background-color': this.bgcolor,
      }
    }
  }
}
</script>

<style lang="scss" scoped="scoped">
  .mark{
    width: 100px;
    height: 100px;
    overflow: hidden;
    position: absolute;
    top: 0;
    left: 0;
  }
.tricon{
    width: 160px;
    height: 20px;
    font-size: 12px;
    color: #fff;
    position: absolute;
    top: 20px;
    left: -50%;
    /*角*/
    transform:rotate(-45deg);
    transform-origin: 50% 50%;
    line-height: 20px;
    text-align: center;
    -webkit-box-shadow:0px 0px 3px #888;
   -moz-box-shadow:0px 0px 3px #888;
    box-shadow: 0px 0px 3px #888;

}
.bookmark{
  /* S 垂直方向的标签 */
  .tag-vertical {
      float: left;  /*水平方向放多个的设置*/
      margin-right: 2px; /*水平方向放多个的设置*/
      position: relative;
      padding: 5px 0;
      width: 40px;
      color: #fff;
      text-align: center;
      font-size: 12px;
  }
  .tag-vertical::after {
      position: absolute;
      content: "";
      left: 0;
      top: 100%;
      border-style: solid;
      border-width: 0 20px 8px 20px;
  }

  /*可设置不同颜色*/
  .tag-vertical.discount::after {
      border-color: #00d9a9 #00d9a9 transparent #00d9a9;
  }
  .tag-vertical.discount {
      background: #00d9a9;
  }
}
</style>
